#===================================================================================#
#                                                 __                                #
#                                                /\ \__                             #
#                    _____   _ __   __  __    ___\ \ ,_\                            #
#                   /\ '__`\/\`'__\/\ \/\ \ /' _ `\ \ \/                            #
#                   \ \ \_\ \ \ \/ \ \ \_\ \/\ \/\ \ \ \_    __   __                #
#                    \ \  __/\ \_\  \/`____ \ \_\ \_\ \__\  /\_\ /\_\               #
#                     \ \ \/  \/_/   `/___/> \/_/\/_/\/__/  \/_/ \/_/               #
#                      \ \_\            /\___/                                      #
#                       \/_/            \/__/                                       #
#                                                                                   #
#===================================================================================#
#@copyright: 2008 by Jeremy Bouillanne
#@license: Apache Public Licence
__revision = '$Revision:  $'[11:-2]

import pylab
from prynt.rest import fig
import prynt

class matplotlib(object):
    showgraph = True
    default_image = 'image-%i'
    __image_count = 1
    def __init__(self):
        pass
    
    def get_new_image_name(self, filetype):
        img_name = prynt.config.getfilepath(self.default_image%self.__image_count, filetype)
        self.__image_count+=1
        return img_name

__config = matplotlib()

def show(filetype="png", **kwargs):
    if __config.showgraph: pylab.show(**kwargs)
    file = __config.get_new_image_name(filetype)
    pylab.savefig(file)
    print fig(file)